use serde::{Deserialize, Serialize};

use crate::features::carts::services::ProductEvent;
use crate::features::quizzes::ddd::{QuizEvent, QuizItemEvent};
use crate::features::tasks::ddd::TaskEvent;

#[rbatis::crud_table(table_name:"events")]
#[derive(Serialize, Deserialize, Clone, Debug)]
/// Event Store
pub struct EventDBO {
  /// event id , HLC format
  pub id: String,
  /// source id, e.g. user.id, quiz.id, quizitem.id,task.id etc.
  pub source: String,
  /// event data content
  pub data: Event,
  /// event user id
  pub user_id: String,
  /// event local created time
  pub created_at: i64,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum Event {
  Quiz(QuizEvent),
  QuizItem(QuizItemEvent),
  Task(TaskEvent),
  Product(ProductEvent),
}
